package com.xb.ai.config;


import cn.dev33.satoken.stp.StpInterface;
import com.xb.ai.entity.po.User;
import com.xb.ai.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;


import java.util.List;

@Component
public class SaTokenConfig  implements StpInterface {

    @Resource
    private IUserService userService;

    @Override
    public List<String> getPermissionList(Object o, String s) {
        return List.of();
    }

    @Override
    public List<String> getRoleList(Object userId, String s) {
        User user = userService.getById((Long) userId);
        if (user != null){
            return List.of(user.getUserRole());
        }
        return List.of();
    }
}
